package com.example.interview.process;

import java.io.IOException;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-04-05
 * Time:21:02
 * Text：进程的建立
 */
public class processDemo {
        public static void main(String[] args) {
            try {
                // 通过 ProcessBuilder 创建一个新的进程
                ProcessBuilder processBuilder = new ProcessBuilder("notepad.exe");
                Process process = processBuilder.start();

                // 等待进程结束
                int exitCode = process.waitFor();
                System.out.println("进程已结束，退出码为：" + exitCode);
            } catch (IOException | InterruptedException e) {
                e.printStackTrace();
            }
        }
}
